package Long.Lu.Dao;


import Long.Lu.pojo.RecruitManager;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface RecruitManagerDao extends JpaRepository<RecruitManager,Integer> {

//事务注解,自定义 sql ，做增、删、改操作，必须加的注解，否则报错
    @Transactional
//@Modifying 表示执行增、删、改操作，clearAutomatically = true 表示清理实体类里的数据。
    @Modifying(clearAutomatically = true)
//@Query 定义sql的注解。nativeQuery = true 表示定义是sql语句，false 是定HQL语句
    @Query(value="UPDATE recruit_manager set state =:state where rId=:rId",nativeQuery = true)
    void updateStateById(Integer state, Integer rId);


    //批量删除用户
    @Transactional
    @Modifying(clearAutomatically = true)
    //@Query 定义sql的注解。nativeQuery = true 表示定义是sql语句，false 是定HQL语句
    @Query(value="delete  from recruit_manager  where r_id in(:rIds)",nativeQuery = true)
    void deleteAll(@Param("rIds") List<String> rIds);


}
